/**
 * @Author: linzp
 * @Date: 2021/08/19/10:39
 * 保证了创建的是同一个实例但是 线程不安全
 */
public class test_1 {
    public static void main(String[] args) {
//        Singleton_1 instance = Singleton_1.getInstance();
//        Singleton_1 instance2 = Singleton_1.getInstance();
//        Singleton_2 instance3 = Singleton_2.getInstance();
//        Singleton_2 instance4 = Singleton_2.getInstance();
//
//
//        System.out.println(instance == instance2);//true
//        System.out.println(instance3 == instance4);//true

        for (int i =0;i<=1000;i++){
            new Thread(new Runnable(){
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName()+" : "+Singleton_1.getInstance().hashCode());
                }
            }).start();
        }


    }
}
